package com.cloudservice.ccs.model;

import com.cloudservice.ccs.entity.Session;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@Data
public class SessionWithLatestMessage extends Session {

    private String latestMessageContent;

    @JsonFormat(pattern = "MM-dd HH:mm")
    private Date latestMessageTime;

    public static SessionWithLatestMessage fromSession(Session session) {
        SessionWithLatestMessage result = new SessionWithLatestMessage();
        result.setChannel(session.getChannel());
        result.setCreateTime(session.getCreateTime());
        result.setCustomerMsgNum(session.getCustomerMsgNum());
        result.setCustomerServiceId(session.getCustomerServiceId());
        result.setCustomerServiceMsgNum(session.getCustomerServiceMsgNum());
        result.setEvaluation(session.getEvaluation());
        result.setEvaluationDetail(session.getEvaluationDetail());
        result.setEvaluationTime(session.getEvaluationTime());
        result.setFinishTime(session.getFinishTime());
        result.setFirstResponeTime(session.getFirstResponeTime());
        result.setSessionId(session.getSessionId());
        result.setVisiterName(session.getVisiterName());
        result.setVisitorIp(session.getVisitorIp());
        return result;
    }

}
